package com.edu.controller;

import com.edu.entity.HfdClassInfo;
import com.edu.service.ISearchService;
import com.edu.vo.PageResultVO;
import com.edu.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private ISearchService iSearchService;

    /**
     * es库初始化
     * @return
     */
    @RequestMapping("/init")
    public Result init(){
        iSearchService.initData2es();
        return new Result(true , 0 ,"初始化成功");
    }

    /**
     * 站内搜索功能，需要接受首页传来到搜索信息，当前页数，每页记录数，和一些过滤信息。所以直接用map集合装
     * @return
     */
    @RequestMapping("/search")
    public PageResultVO search(@RequestBody Map searchMap){
        return iSearchService.search(searchMap);

    }

//    @RequestMapping("/course2es")
//    public Result course2es(@RequestBody HfdClassInfo hfdClassInfo){
//
//        return iSearchService.course2es(hfdClassInfo);
//    }
}
